﻿using System.ComponentModel.DataAnnotations.Schema;
using OpenAdmin.Core.DbContextLocators;

namespace OpenAdmin.Core.Models;

[Table("Posts")]
public class Post : EntityBase<BloggingDbContextLocator>, IEntityTypeSeedDataConfigure<Post>
{
    public string Title { get; set; }
    public string Content { get; set; }

    public int BlogId { get; set; }
    public Blog Blog { get; set; }

    public IEnumerable<Post> HasData(DbContext dbContext)
    {
        return new List<Post>()
        {
            new Post { Id = 1, BlogId = 1, Title = "Hello World 1", Content = "I wrote an app using EF Core 1!", CreateTime = DateTime.Now },
            new Post { Id = 2, BlogId = 2,  Title = "Hello World 2", Content = "I wrote an app using EF Core 2!", CreateTime = DateTime.Now }
        };
    }
}
